﻿using Microsoft.Practices.Unity;
using SampleServiceInterfacesAndImplementation;

namespace UnitySamples
{
    public class Container_Configured_Registration_of_Existing_Object_Instances
    {
        /*
         * As an example of using the overloads of the RegisterInstance and 
         * Resolve methods, the following code registers an existing instance 
         * of a class named LoggingService that implements the interface 
         * IMyService and then retrieves that instance.
         * 
         */
        static void Sample()
        {
            IUnityContainer myContainer = new UnityContainer();
            ILogger myExistingObject = new TraceLogger();
            myContainer.RegisterInstance<ILogger>(myExistingObject);
            ILogger myServiceInstance = myContainer.Resolve<ILogger>();
        }
    }
}